package com.alks.function.controller.chengKong;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.chengKong.*;
import com.alks.function.service.chengKong.PcOutListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@ApiRestController("/Outgoing")
@Api(tags = {"成控部-工厂生产作业-指令外发作业","成控部-工厂生产作业-冲裁外发作业","成控部-工厂生产作业-补单外发作业"})
@Slf4j
public class PcOutListController {

    @Resource
    private PcOutListService pcOutListService;

    @WebLogger
    @PostMapping("/getOutsourcedProjectsList")
    @ApiOperation(value = "外发项目建档-外加工项目明细",tags = "成控部-工厂生产作业-指令外发作业")
    public ResponseInfo getOutsourcedProjectsList(){
        return pcOutListService.getOutsourcedProjectsList();
    }

    @WebLogger
    @PostMapping("/getOutsourcedProjectsAdd")
    @ApiOperation(value = "外发项目建档-建档作业-插入",tags = "成控部-工厂生产作业-指令外发作业")
    public ResponseInfo getOutsourcedProjectsAdd(@RequestBody@ApiParam(value = "{partName:值}") Map<String,String> param){
        return pcOutListService.getOutsourcedProjectsAdd(param);
    }

    @WebLogger
    @PostMapping("/getOutsourcedProjectsUpdate/{partSeq}")
    @ApiOperation(value = "外发项目建档-建档作业-修改",tags = "成控部-工厂生产作业-指令外发作业")
    public ResponseInfo getOutsourcedProjectsUpdate(@RequestParam @ApiParam(value = "0 不勾选,1勾选") Integer param, @PathVariable(value = "partSeq") Integer partSeq){
        return pcOutListService.getOutsourcedProjectsUpdate(param, partSeq);
    }

    @WebLogger
    @PostMapping("/getOutsourcedProjectsDel/{partSeq}")
    @ApiOperation(value = "外发项目建档-建档作业-删除",tags = "成控部-工厂生产作业-指令外发作业")
    public ResponseInfo getOutsourcedProjectsDel(@PathVariable(value = "partSeq") Integer partSeq) {
        return pcOutListService.getOutsourcedProjectsDel(partSeq);
    }

    @WebLogger
    @PostMapping("/getChooseOutsourcedProjects")
    @ApiOperation(value = "选择外发项目",tags = "成控部-工厂生产作业-指令外发作业")
    public ResponseInfo getChooseOutsourcedProjects(@RequestBody LotNoToStyleRequest request) {
        return pcOutListService.getChooseOutsourcedProjects(request);
    }

    @WebLogger
    @PostMapping("/getChooseOutgoingInstructionsList")
    @ApiOperation(value = "选择外发项目-选择外发指令查询",tags = "成控部-工厂生产作业-指令外发作业")
    public ResponseInfo getChooseOutgoingInstructionsList(@RequestBody LotNoRequest request) {
        return pcOutListService.getChooseOutgoingInstructionsList(request);
    }

    @WebLogger
    @PostMapping("/GenerateOutsourcedMaterials/{type}")
    @ApiOperation(value = "选择外发项目-生成外发资料",tags = "成控部-工厂生产作业-指令外发作业")
    public ResponseInfo GenerateOutsourcedMaterials(@RequestBody GenerateOutsourcedMaterialsRequest request, @PathVariable@ApiParam("0 冲裁外发 1 工艺外发  2 补单外发 3 指令外发")int type) {
        return pcOutListService.GenerateOutsourcedMaterials(request,type);
    }

    @WebLogger
    @PostMapping("/getOutsourcedDetailsList")
    @ApiOperation(value = "外发明细",tags = "成控部-工厂生产作业-指令外发作业")
    public ResponseInfo getOutsourcedDetailsList(@RequestBody OutGoingQueryRequest request) {
        return pcOutListService.getOutsourcedDetailsList(request);
    }

    @WebLogger
    @PostMapping("/getOutsourcedNumberDetailsList")
    @ApiOperation(value = "外发号码明细",tags = "成控部-工厂生产作业-指令外发作业")
    public ResponseInfo getOutsourcedNumberDetailsList(@RequestBody OutGoingNumberQueryRequest request) {
        return pcOutListService.getOutsourcedNumberDetailsList(request);
    }

    @WebLogger
    @PostMapping("/getFormAnExternalProcessingOrder")
    @ApiOperation(value = "形成外加工单",tags = "成控部-工厂生产作业-指令外发作业")
    public ResponseInfo getFormAnExternalProcessingOrder(@RequestBody OutGoingOrderRequest request) {
        return pcOutListService.getFormAnExternalProcessingOrder(request);
    }

    @WebLogger
    @GetMapping("/DeleteTheEntireAdditionalOrder")
    @ApiOperation(value = "整个加工单删除",tags = "成控部-工厂生产作业-指令外发作业")
    public ResponseInfo DeleteTheEntireAdditionalOrder(@RequestParam  String slipNo) {
        return pcOutListService.DeleteTheEntireAdditionalOrder(slipNo);
    }

    @WebLogger
    @GetMapping("/ExportContract")
    @ApiOperation(value = "导出合同",tags = "成控部-工厂生产作业-指令外发作业")
    public void ExportContract(@RequestParam  String slipNo, HttpServletResponse response) {
         pcOutListService.ExportContract(slipNo,response);
    }

    @WebLogger
    @PostMapping("/ExportDetails")
    @ApiOperation(value = "导出明细",tags = "成控部-工厂生产作业-指令外发作业")
    public void ExportDetails(@RequestBody OutGoingQueryRequest request, HttpServletResponse response) {
        pcOutListService.ExportDetails(request,response);
    }

    @WebLogger
    @PostMapping("/SelectPartProcess/{flag}")
    @ApiOperation(value = "选择部位工艺-选择外发指令查询",tags = "成控部-工厂生产作业-冲裁外发作业")
    public ResponseInfo SelectPartProcess(@RequestBody LotNoRequest request,@PathVariable(value = "flag")@ApiParam("0 冲裁外发,1 工艺外发") int flag) {
        return pcOutListService.SelectPartProcess(request,flag);
    }

    @WebLogger
    @PostMapping("/SelectPartProcessQuery")
    @ApiOperation(value = "选择部位工艺查询",tags = "成控部-工厂生产作业-补单外发作业")
    public ResponseInfo SelectPartProcessQuery(@RequestBody@ApiParam("newLotNo 补料") LotNo2Request request) {
        return pcOutListService.SelectPartProcessQuery(request);
    }

    @WebLogger
    @PostMapping("/SupplementaryOrderSelectionOutsourcingInstruction")
    @ApiOperation(value = "选择外发加工-选择外发指令查询",tags = "成控部-工厂生产作业-补单外发作业")
    public ResponseInfo SupplementaryOrderSelectionOutsourcingInstruction(@RequestBody@ApiParam("newLotNo 补料") LotNo2Request request) {
        return pcOutListService.SupplementaryOrderSelectionOutsourcingInstruction(request);
    }

    @WebLogger
    @PostMapping("/PartReplacementOrderOutsourcing")
    @ApiOperation(value = "选择部位加工-选择外发指令查询",tags = "成控部-工厂生产作业-补单外发作业")
    public ResponseInfo PartReplacementOrderOutsourcing(@RequestBody@ApiParam("newLotNo 补料") LotNo2Request request) {
        return pcOutListService.PartReplacementOrderOutsourcing(request);
    }
}
